home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / Bento / CM / CMVHOps.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  6.0 KB  |  173 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CMVHOps.c
  3.  
  4.     Contains:    Container Manager (Dynamic) Value Handler Operations
  5.  
  6.     Written by:    Ira L. Ruben
  7.  
  8.     Owned by:    Ed Lai
  9.  
  10.     Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     Change History (most recent first):
  13.  
  14.          <2>     8/26/94    EL        #1181622 Ownership update.
  15.          <1>      2/3/94    EL        first checked in
  16.  
  17.     To Do:
  18. */
  19.  
  20. /*---------------------------------------------------------------------------*
  21.  |                                                                           |
  22.  |                        <<<      CMVHOps.c      >>>                        |
  23.  |                                                                           |
  24.  |            Container Manager (Dynamic) Value Handler Operations           |
  25.  |                                                                           |
  26.  |                               Ira L. Ruben                                |
  27.  |                                  7/27/92                                  |
  28.  |                                                                           |
  29.  |                    Copyright Apple Computer, Inc. 1992-1994               |
  30.  |                           All rights reserved.                            |
  31.  |                                                                           |
  32.  *---------------------------------------------------------------------------*
  33.  
  34.  This routines in this file are used for dynamic values.  Currently one one special 
  35.  routines is defined to aid a dynamic value's "new value" handler in getting its
  36.  "constructor" (initialization) parameters from CMNewValue().  See CMScanDataPacket()
  37.  for further details.
  38. */
  39.  
  40.  
  41. #include <stddef.h>
  42. #include <stdio.h>
  43.  
  44. #ifndef __CMTYPES__
  45. #include "CMTypes.h"
  46. #endif
  47. #ifndef __CM_API__
  48. #include "CMAPI.h"
  49. #endif
  50. #ifndef __LISTMGR__
  51. #include "ListMgr.h"
  52. #endif
  53. #ifndef __TOCENTRIES__
  54. #include "TOCEnts.h"   
  55. #endif
  56. #ifndef __TOCOBJECTS__
  57. #include "TOCObjs.h"   
  58. #endif
  59. #ifndef __HANDLERS__
  60. #include "Handlers.h"
  61. #endif
  62. #ifndef __CONTAINEROPS__
  63. #include "Containr.h"  
  64. #endif
  65. #ifndef __SESSIONDATA__
  66. #include "Session.h"          
  67. #endif
  68. #ifndef __ERRORRPT__
  69. #include "ErrorRpt.h"      
  70. #endif
  71.                                                                     
  72.                                                                     CM_CFUNCTIONS
  73.  
  74. /* The following generates a segment directive for Mac only due to 32K Jump Table             */
  75. /* Limitations.  If you don't know what I'm talking about don't worry about it.  The        */
  76. /* default is not to generate the pragma.  Theoritically unknown pragmas in ANSI won't    */
  77. /* choke compilers that don't recognize them.  Besides why would they be looked at if        */
  78. /* it's being conditionally skipped over anyway?  I know, famous last words!                        */
  79.  
  80. #if CM_MPW
  81. #pragma segment CMHandlerOps
  82. #endif
  83.                                                                     
  84.  
  85. /*--------------------------------------------------------*
  86.  | CMScanDataPacket - extract the data from a data packet |
  87.  *--------------------------------------------------------*
  88.  
  89.  This routine is used by a dynamic value's "new value" handler to extract the fields of
  90.  a data packet passed to it by the Container Manager.  The data packet represents all
  91.  the CMNewValue() "..." parameters for the type also passed to the "new value hander".
  92.  
  93.  Only that portion of the CMNewValue() "..." parameters associated with the type are passed
  94.  in the data packet.  The Container Manager determines the parameters by the placement
  95.  of the type within its heirarchy (types may have base types) and the metadata.
  96.  
  97.  The Container Manager accesses the metadata through a "metadata" handler for the type to
  98.  build the data packet.  CMScanDataPacket() inverts the the operation and allows the "new
  99.  value" handler to extract the data back into distinct variables.  The "new value" handler
  100.  can use its own "metadata" handler to pass to the CMScanDataPacket() routine to extract
  101.  the data.  Each CMScanDataPacket() "..." parameter must be a pointer; extracted data read
  102.  from the data packet are stored into the locations pointed to by the pointers.
  103.  
  104.  The function returns the number of data items extracted and assigned to the parameters.
  105.  This could be 0 if metadata is passed as NULL, or if an error is reported and the error
  106.  reporter returns.
  107.   
  108.  See DynamicValues.[hc] for a full description of the "metadata" handler and metadata
  109.  format specifications.
  110. */
  111.  
  112. CMCount CM_VARARGS CMScanDataPacket(CMType type, CMMetaData metaData,
  113.                                                                         CMDataPacket dataPacket, ...)
  114. {
  115.     va_list             dataInitParams;
  116.     CM_ULONG            nbrAssigned;
  117.     
  118.     ExitIfBadType(type, 0);                                                        /* validate type                                        */
  119.         
  120.     va_start(dataInitParams, dataPacket);                            /* extract data into "..." variables*/
  121.     nbrAssigned = cmVScanDataPacketGuts((TOCObjectPtr)type, (CM_CHAR *)metaData,
  122.                                                                             (CM_UCHAR *)dataPacket, dataInitParams);
  123.     va_end(dataInitParams);
  124.     
  125.     return ((CMCount)nbrAssigned);                                        /* return nbr of values assigned        */
  126. }
  127.  
  128.  
  129. /*--------------------------------------------------------*
  130.  | CMVScanDataPacket - extract the data from a data packet |
  131.  *--------------------------------------------------------*
  132.  
  133.  This routine is the same as CMScanDataPacket() above, except that the CMNewValue()
  134.  "..." parameters are given as a variable argument list as defined by the "stdarg"
  135.  facility.
  136.  
  137.  This routine assumes the caller sets up and terminates the variable arg list using the
  138.  "stdarg.h" calls as follows:
  139.  
  140.              #include <stdarg.h>
  141.             
  142.              callersRoutine(args, ...)
  143.             {
  144.                 va_list dataInitParams;
  145.                 
  146.                 - - -
  147.                 
  148.                 va_start(dataInitParams, args);
  149.                 n = CMScanDataPacket(type, metaData, dataPacket, dataInitParams);
  150.                 va_end(dataInitParams);
  151.                 
  152.                 - - -
  153.             }
  154.             
  155.  See CMScanDataPacket() for further details.
  156. */
  157.  
  158. CMCount CM_FIXEDARGS CMVScanDataPacket(CMType type, CMMetaData metaData,
  159.                                                                              CMDataPacket dataPacket,
  160.                                                                               va_list dataInitParams)
  161. {
  162.     CM_ULONG    nbrAssigned;
  163.     
  164.     ExitIfBadType(type, 0);                                                        /* validate type                                        */
  165.         
  166.     nbrAssigned = cmVScanDataPacketGuts((TOCObjectPtr)type, (CM_CHAR *)metaData,
  167.                                                                             (CM_UCHAR *)dataPacket, dataInitParams);
  168.     
  169.     return ((CMCount)nbrAssigned);                                        /* return nbr of values assigned        */
  170. }
  171.                                                           
  172.                                                             CM_END_CFUNCTIONS
  173.